
const IS_DEBUG = process.env.NODE_ENV == 'development';

const awwitTime = (time: number = 100) => {
    return new Promise<void>((resolve) => {
        setTimeout(() => {
            resolve();
        }, time);
    });
};

const awaitFind = async (find: () => Promise<any | boolean>): Promise<any> => {
    const result = await find();
    if (result != undefined) {
        return result;
    }
    if (result == false) {
        return;
    }
    awwitTime();
    return await awaitFind(find);

}


const getAppName = () => {
    if(IS_DEBUG){
        return 'TEST';
    }
    return import.meta.env['APP_NAME'];

}

export { awaitFind, awwitTime, getAppName };